//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:20-4-20
// @Time:上午11:46
//

#ifndef GEEJOAN_COMMONTOOL_H
#define GEEJOAN_COMMONTOOL_H

#include <cstddef>
#include <cstdint>
#include <string>
/**
 * @brief 通用型工具类
 */
namespace GeeJoan
{
    namespace Common
    {   /**
         * @brief 通用异常
         */
        class CommonException : public std::exception
        {
        private:
            int errCode = 0;
            std::string errMsg;
        public:
            /**
             * @brief 抛出的异常结构
             * @param errcode 错误码
             * @param errmsg 错误信息
             */
            explicit CommonException(int errcode = 0, std::string errmsg = "")
            {
                errCode = errcode;
                errMsg = errmsg;
            }

            int code() const throw()
            {
                return errCode;
            }

            const std::string &getErrMsg() const
            {
                return errMsg;
            }

            const char *what() const throw()
            {
                return "GeeJoan::Security::Common::CommonException";
            }
        };


        std::string StringToHex(const std::string &data);

        std::string HexToString(const std::string &data);

        std::string genTaskCode();
    }
}


#endif //GEEJOAN_COMMONTOOL_H
